MarkLogic Server 11.0 Product Documentation
POST /manage/v2/databases/{id|name}/triggers

Summary

This resource address creates a new trigger.

URL Parameters
format The format of the data in the request body. Allowed values: html, json or xml (default). Use this parameter to override the Accept header.
Request Headers
Accept The expected MIME type of the request body. If the format? parameter is present, it takes precedence over the Accept header.
Content-type The MIME type of the data in the request body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Response Headers
Content-type The MIME type of the data in the response body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.
Location If the request causes a restart, a Location header is included in the reponse. The header contains a path with which to construct a URL to usable to test when the restart has completed.

Response

Upon success, MarkLogic Server returns status code 200 (OK). If the trigger already exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.

Required Privileges

This operation requires one of the following:

Usage Notes

The structure of the data in a create trigger request is as shown below.

id

The trigger ID.

name

The trigger name.

description

The trigger description.

event

The description of event.

This is a complex structure with the following children:

data-event

The description of triggering events.

This is a complex structure with the following children:

document-scope

The scope of a single document for a trigger.

This is a complex structure with the following children:

uri

The URI.

collection-scope

The scope of all documents in a collection for a trigger.

This is a complex structure with the following children:

uri

The URI.

directory-scope

The scope of descendant documents of a directory for a trigger.

This is a complex structure with the following children:

uri

The URI.

depth

The depth.

document-content

The document content.

This is a complex structure with the following children:

update-kind

The kind of update.

any-property-content

The document properties.

any-custom-property-content

The custom document properties.

property-content

The specific document property.

This is a complex structure with the following children:

property-name

The QName of a property.

This is a complex structure with the following children:

namespace-uri

The namespace URI.

localname

The localname.

when

The timing of the event.

database-online-event

The description of a database coming online.

This is a complex structure with the following children:

user

The user unique ID.

user-id

The user unique ID.

user-name

The user unique name.

module

The module path

module-db

The module database

module-root

The module root

enabled

Whether the trigger is enabled or not.

recursive

Whether the trigger is recursive or not.

task-priority

The post-commit task priority.

permissions

The default set of permissions used in document creation.

This is a complex structure with the following children:

permission

Permission representation.

This is a complex structure with the following children:

role-name

The Role name (unique)

capability

The action/task permitted by a permission

Example


curl -X POST  --anyauth --user admin:admin --header "Content-Type:application/json" \
-d '{
  "name": "my-trigger",
  "description": "my trigger",
  "event": {
    "data-event": {
      "directory-scope": {
        "uri": "/myDir/",
        "depth": "1"
      },
      "document-content": {
        "update-kind": "create"
      },
      "when": "post-commit"
    }
  },
  "module": "/test.xqy",
  "module-db": "Modules",
  "module-root": "/modules/",
  "enabled": true,
  "recursive": true,
  "task-priority": "normal"
   }' \
http://localhost:8002/manage/v2/databases/myTriggers/triggers

==>  Creates a new trigger, named "my-trigger," for the myTriggers
     database. 
    
Powered by MarkLogic Server | Terms of Use | Privacy Policy